drop _all
set more off
set logtype text
capture log close
log using penn_create, replace

insheet using penn.txt, tab
rename year yearc
rename rgdpch gdp

label var gdp "Real GDP per capita, chain index"
label var pop "Population, in 000's"
tab country 
sort country
egen countryid=group(country)
tab countryid

** generate logged GDP

gen lgdp=ln(gdp)
label var lgdp "Log Real GDP per capita, chain index"

save penn.dta, replace

** now create averages

sort country yearc
collapse gdp, by(country)
save penn_avgs.dta, replace

log close
exit
